import Vue from 'vue'
import Router from 'vue-router'
import Home from 'components/home/home'
import Find from 'components/home/find/find'
import Order from 'components/home/order/order'
import Take from 'components/home/take/take'
import Mine from 'components/home/mine/mine'
import Seller from 'components/seller/seller'
import GoodList from 'components/seller/goodList/goodList'

Vue.use(Router)

var router = new Router({
  linkActiveClass: 'active',
  routes: [
    {
      path: '/',
      redirect: '/home/take'
    },
    {
      path: '/home',
      component: Home,
      children: [
        {
          path: 'take',
          name: 'take',
          component: Take,
          meta: {
            title: '首页'
          }
        },
        {
          path: 'order',
          name: 'order',
          component: Order,
          meta: {
            title: '订单'
          }
        },
        {
          path: 'mine',
          name: 'mine',
          component: Mine,
          meta: {
            title: '我的'
          }
        },
        {
          path: 'find',
          name: 'find',
          component: Find,
          meta: {
            title: '发现'
          }
        }
      ]
    },
    {
      path: '/seller',
      name: 'seller',
      component: Seller,
      children: [
        {
          path: 'goodList',
          name: 'goodList',
          component: GoodList
        }
        // {
        //   path: 'rating'
        // }
      ]
    }
  ]
})

router.beforeEach((to, from, next) => {
  if (to.meta.title) {
    document.title = to.meta.title
  }
  next()
})

export default router
